//
//  AppDelegate.m
//  SHNet
//
//  Created by FranklinPhill on 15/12/17.
//  Copyright © 2015年 Fire. All rights reserved.
//

#import "AppDelegate.h"
#import "SpecialVC.h"

@interface AppDelegate ()

@property (strong, nonatomic) UINavigationController *topNavigationController;
@property (strong, nonatomic) SpecialVC *sVC;
@property (strong, nonatomic) UIViewController *launchVC;

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(webViewLoadFinished:) name:webViewLoadFinishedNotification object:nil];
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self initUI];
    [self initLaunchView];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {}

- (void)applicationDidEnterBackground:(UIApplication *)application {}

- (void)applicationWillEnterForeground:(UIApplication *)application {}

- (void)applicationDidBecomeActive:(UIApplication *)application {}

- (void)applicationWillTerminate:(UIApplication *)application {}

- (void)webViewLoadFinished:(NSNotification *)notification {
    DLog(@"收到消息");
    [_launchVC.view removeFromSuperview];
    self.launchVC = nil;
}

- (void)initUI {
    self.sVC = [StoryBoard(@"SHNet") instantiateViewControllerWithIdentifier:@"SpecialVCSID"];
    self.topNavigationController = [[UINavigationController alloc] initWithRootViewController:_sVC];
    self.window.rootViewController = _topNavigationController;
    [self.window addSubview:_topNavigationController.view];
}

- (void)initLaunchView {
    DLog(@"========initLaunchView");
    self.launchVC = [StoryBoard(@"LaunchScreen") instantiateViewControllerWithIdentifier:@"LaunchVCSID"];
    [self.window addSubview:_launchVC.view];
    [self.window bringSubviewToFront:_launchVC.view];
    [self.window makeKeyAndVisible];
}

@end
